package scala

import main.scala.AST._

class TestSimplifySum extends Test {
	
	test("sum integers") {
	  val ref = NumI(196)
	  assertSimplifyString("4+110+70+5+5+2", ref)
	}
	
	test("sum and subtract integers") {
	  val ref = NumI(6)
	  assertSimplifyString("8+2-6+2", ref)
	}
	
	test("first int in sum is negative") {
	  val ref = NumI(6)
	  assertSimplifyString("-6+8+2+2", ref)
	}
	
	test("int sum, result is zero") {
	  val ref = NumI(0)
	  assertSimplifyString("-6+8+2-4", ref)
	}
	
	test("sum removal") {
	  var ref = NumI(4)
	  assertSimplifyString("3+1", ref)
	}
	
	test("sum zero removal") {
	  var ref = NumI(0)
	  assertSimplifyString("0+0", ref)
	}
	
	test("sum with variable") {
	  assertSimplifyString("0+a", Var("a"))
	  assertSimplifyString("1+a", Add(List(NumI(1), Var("a"))))
	}
	
	test("sum int and double") {
	  assertSimplifyString("1+1.0", NumD(2.0))
	}
	
	test("sum doubles") {
	  assertSimplifyString("2.0+7.0", NumD(9.0))
	  assertSimplifyString("2.0+7.4", NumD(9.4))
	  assertSimplifyString("2.6+7.4", NumD(10.0))
	}
	
	
	test("sum variables and numbers") {
	  var ref = Add(List(NumI(8), Var("a"), Var("b")))
	  assertSimplifyString("a+1+b-2+9", ref)
	}
	
	ignore("sum variables, numbers and powers") {
	  var ref = Add(List(Var("a"), Var("b"), NumI(8)))
	  assertSimplifyString("a+1+k+10^l-20+i^a+h^0", ref)
	}
	
	ignore("sum variables, numbers, powers, modulos") {
	  var ref = Add(List(Var("a"), Var("b"), NumI(8)))
	  assertSimplifyString("a+1+10^l-i^a+2%i", ref)
	}
	
	ignore("sum variables, numbers, powers, modulos, divisions") {
	  var ref = Add(List(Var("a"), Var("b"), NumI(8)))
	  assertSimplifyString("a+1+10^l+2%i-(3/w)+(8/2)", ref)
	}
	
}